from argparse import ArgumentParser
import mmap
from math import floor
from struct import unpack

PL_BASE = 0x200D00


def main():
    parser = ArgumentParser()
    parser.add_argument('file')
    args = parser.parse_args()

    file = open(args.file, 'rb')
    data = mmap.mmap(file.fileno(), 0, access=mmap.ACCESS_READ)

    for i in range(floor(len(data)-4)):
        word = unpack('<I', data[i:i+4])[0] & 0xffffffff
        if word == 0:
            continue
        addr = word - PL_BASE
        if addr >= len(data) or addr < 0:
            continue

        try:
            t = data[addr:-1].find(b'\x00')
            if t <= 0:
                continue

            print('%08x' % addr, data[addr:addr+t].decode('utf-8'))
            #print('%08x' % addr, data[addr:addr+12])
        except:
            pass


if __name__ == '__main__':
    main()
